package com.steel.yfmall.cloud.assistant.view.impl;

import com.alibaba.fastjson.JSONObject;
import com.steel.yfmall.cloud.assistant.bean.result.APIResultByProductPriceBean;
import com.steel.yfmall.cloud.assistant.dto.para.view.ParaByProductPriceBean;
import com.steel.yfmall.cloud.assistant.dto.zg.SynZgResult;
import com.steel.yfmall.cloud.assistant.dto.zg.ZgSOResultBean;
import com.steel.yfmall.cloud.assistant.dto.zg.ZgViewBean;
import com.steel.yfmall.cloud.assistant.po.view.ByProductPriceBean;
import com.steel.yfmall.cloud.assistant.po.view.ByProductPriceBeanExample;
import com.steel.yfmall.cloud.assistant.po.view.ByProductPriceBeanExample.Criteria;
import com.steel.yfmall.cloud.assistant.view.ByProductPriceBeanService;
import com.steel.yfmall.cloud.assistant.view.mapper.ByProductPriceBeanMapper;
import com.steel.yfmall.cloud.assistant.zg.ZgSOService;
import com.steel.yfmall.cloud.components.utils.base.APIMsgBean;
import com.steel.yfmall.cloud.components.utils.base.Pages;
import com.steel.yfmall.cloud.components.utils.base.ResponseCode;
import com.steel.yfmall.cloud.components.utils.utils.MobileBaseBeanUtils;
import com.steel.yfmall.cloud.components.utils.utils.UtilDate;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.annotation.Resource;
import java.util.*;

/**
 * 副产品单价信息业务逻辑实现
 *
 * @author jia chang bao
 * @date 2020/11/11 15:16
 */
@Service
@Slf4j
public class ByProductPriceBeanServiceImpl implements ByProductPriceBeanService {

    @Resource
    ByProductPriceBeanMapper byProductPriceBeanMapper;

    @Resource
    ZgSOService zgSOService;

    /**
     * 获取副产品单价信息总条数
     *
     * @param paraByProductPriceBean 参数
     * @return 总条数
     */
    @Override
    public long getProductPriceBeanCount(ParaByProductPriceBean paraByProductPriceBean) {
        ByProductPriceBeanExample byProductPriceBeanExample = new ByProductPriceBeanExample();
        Criteria criteria = byProductPriceBeanExample.createCriteria();
        //条件
        if (!ObjectUtils.isEmpty(paraByProductPriceBean)) {
            getSearchData(criteria, paraByProductPriceBean);
        }
        return byProductPriceBeanMapper.countByExample(byProductPriceBeanExample);
    }

    /**
     * 根据条件分页查询副产品单价信息（分页）
     *
     * @param paraByProductPriceBean 分页查询条件
     * @return 分页结果
     */
    @Override
    public Pages<ByProductPriceBean> getByProductPriceBeanOfPage(ParaByProductPriceBean paraByProductPriceBean) {
        Pages<ByProductPriceBean> returnBean = new Pages<>();
        if (ObjectUtils.isEmpty(paraByProductPriceBean)) {
            return returnBean;
        }
        //条件
        ByProductPriceBeanExample byProductPriceBeanExample = new ByProductPriceBeanExample();
        Criteria criteria = byProductPriceBeanExample.createCriteria();
        getSearchData(criteria, paraByProductPriceBean);
        //获取总页数
        long result_count_int = byProductPriceBeanMapper.countByExample(byProductPriceBeanExample);
        //分页
        returnBean.paging(paraByProductPriceBean.getCurrentPage(), paraByProductPriceBean.getPageSize(), result_count_int);
        byProductPriceBeanExample.limit(returnBean.getStartPosition(), paraByProductPriceBean.getPageSize());
        if (StringUtils.isNotBlank(paraByProductPriceBean.getOrderByValue())) {
            byProductPriceBeanExample.setOrderByClause(paraByProductPriceBean.getOrderByValue());
        }
        //分页结果
        List<ByProductPriceBean> byProductPriceBeans = byProductPriceBeanMapper.selectByExample(byProductPriceBeanExample);
        returnBean.setList(byProductPriceBeans);
        return returnBean;
    }

    /**
     * 根据条件不分页查询副产品单价信息 (不分页)
     *
     * @param paraByProductPriceBean 不分页查询参数
     * @return 不分页结果
     */
    @Override
    public List<ByProductPriceBean> getByProductPriceBeanOfList(ParaByProductPriceBean paraByProductPriceBean) {
        //条件为空返回空
        if (ObjectUtils.isEmpty(paraByProductPriceBean)) {
            return null;
        }
        ByProductPriceBeanExample byProductPriceBeanExample = new ByProductPriceBeanExample();
        Criteria criteria = byProductPriceBeanExample.createCriteria();
        getSearchData(criteria, paraByProductPriceBean);
        //不分页结果
        return byProductPriceBeanMapper.selectByExample(byProductPriceBeanExample);
    }

    /**
     * 单条新增
     *
     * @param byProductPriceBean 添加参数信息
     * @return 受影响行数
     */
    @Override
    public int addByProductPriceBean(ByProductPriceBean byProductPriceBean) {
        return byProductPriceBeanMapper.insert(byProductPriceBean);
    }

    /**
     * 批量新增
     *
     * @param byProductPriceBeans 添加参数信息
     * @return 受影响行数
     */
    @Override
    public int addByProductPriceBeanOfList(List<ByProductPriceBean> byProductPriceBeans) {
        return byProductPriceBeanMapper.batchInsertByList(byProductPriceBeans);
    }

    /**
     * 修改副产品单价信息
     *
     * @param ByProductPriceBean 修改参数条件
     * @return 受影响行数
     */
    @Override
    public int updateByProductPriceBean(ByProductPriceBean ByProductPriceBean) {
        if (ObjectUtils.isEmpty(ByProductPriceBean)) {
            return 0;
        }
        //条件
        ByProductPriceBeanExample byProductPriceBeanExample = new ByProductPriceBeanExample();
        Criteria criteria = byProductPriceBeanExample.createCriteria();
        criteria.andIdEqualTo(ByProductPriceBean.getId()).andCustNoEqualTo(ByProductPriceBean.getCustNo());
        return byProductPriceBeanMapper.updateByExampleSelective(ByProductPriceBean, byProductPriceBeanExample);
    }

    /**
     * 删除副产品单价信息
     *
     * @param paraByProductPriceBean 删除参数条件
     * @return 受影响行数
     */
    @Override
    public int deleteByProductPriceBean(ParaByProductPriceBean paraByProductPriceBean) {
        if (ObjectUtils.isEmpty(paraByProductPriceBean)) {
            return 0;
        }
        //条件
        ByProductPriceBeanExample byProductPriceBeanExample = new ByProductPriceBeanExample();
        Criteria criteria = byProductPriceBeanExample.createCriteria();
        getSearchData(criteria, paraByProductPriceBean);
        return byProductPriceBeanMapper.deleteByExample(byProductPriceBeanExample);
    }

    /**
     * 批量删除副产品单价信息
     *
     * @param paraByProductPriceBeans 删除参数条件
     * @return 受影响行数
     */
    @Override
    public int deleteByProductPriceBeanOfList(List<ParaByProductPriceBean> paraByProductPriceBeans) {
        if (CollectionUtils.isEmpty(paraByProductPriceBeans)) {
            return 0;
        }
        //条件
        ByProductPriceBeanExample byProductPriceBeanExample = new ByProductPriceBeanExample();
        Criteria criteria = byProductPriceBeanExample.createCriteria();
        Map<Integer, String> conditionMap = new HashMap<>();
        for (ParaByProductPriceBean paraByProductPriceBean : paraByProductPriceBeans) {
            conditionMap.put(paraByProductPriceBean.getId(), paraByProductPriceBean.getByProdPriceNo());
        }
        criteria.andIdIn(new ArrayList<>(conditionMap.keySet()));
        return byProductPriceBeanMapper.deleteByExample(byProductPriceBeanExample);
    }

    /**
     * 同步中冠信息
     *
     * @return 同步结果
     */
    @Override
    public APIMsgBean synchronizationZgReceivingGoods(ZgViewBean zgViewBean) {
        APIMsgBean serviceDataBean = new APIMsgBean();
        serviceDataBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean("数据同步失败"));
        //参数校验
        String msg = checkData(zgViewBean);
        if (!StringUtils.isBlank(msg)) {
            serviceDataBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean(msg));
            return serviceDataBean;
        }
        SynZgResult synZgResult = new SynZgResult();
        //同步计时开始
        long begintime = System.currentTimeMillis();
        //查询sr04副产品单价
        ZgSOResultBean viewData = zgSOService.getViewData(zgViewBean);
        //同步计时结束
        long endtime = System.currentTimeMillis();
        long costTime = (endtime - begintime);
        //请求中冠成功后
        if ("Y".equals(viewData.getIsSuccess())) {
            List<ByProductPriceBean> byProductPriceBeans = null;
            try {
                byProductPriceBeans = JSONObject.parseArray(viewData.getData(), ByProductPriceBean.class);
            } catch (Exception e) {
                serviceDataBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean("副产品单价数据同步解析出错"));
                log.error("副产品单价数据同步解析出错，错误信息：", e);
            }
            //检查数据库是否有重复,过滤掉重复信息并设置创建、更新、版本信息
            byProductPriceBeans = checkDataBase(byProductPriceBeans);
            if (!CollectionUtils.isEmpty(byProductPriceBeans)) {
                //批量新增
                int i = addByProductPriceBeanOfList(byProductPriceBeans);
                if (i > 0) {
                    //设置同步所用时间
                    synZgResult.setSynTime(String.valueOf(costTime));
                    //设置同步条数
                    synZgResult.setCountNum(i);
                    //设置同步状态
                    synZgResult.setState(true);
                    serviceDataBean.setSoaStateBean(ResponseCode.buildEnumSuccessSOAStateBean("数据同步成功"));
                    serviceDataBean.setData(synZgResult);
                    //日志记录
                    log.info("副产品单价数据同步成功，本次同步" + i + "条数据,耗时" + costTime + "毫秒");
                }
            } else {
                log.info("无数据同步");
                serviceDataBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean("无数据同步"));
            }
        } else {
            serviceDataBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean(viewData.getMsg()));
        }
        //递归同步
        try {
            //起始页
            int startPage = Integer.parseInt(zgViewBean.getPageNum());
            //判断是否还有数据
            if (startPage < viewData.getZgpageData().getPages()) {
                startPage++;
                zgViewBean.setPageNum(String.valueOf(startPage));
                synchronizationZgReceivingGoods(zgViewBean);
            }
        } catch (Exception e) {
            serviceDataBean.setSoaStateBean(ResponseCode.buildEnumErrorSOAStateBean("副产品单价数据递归同步出错"));
            log.error("副产品单价数据递归同步出错，错误信息：", e);
        }
        return serviceDataBean;
    }

    /***
     * 检查数据库中数据是否存在，将不存在的数据返回，过滤掉重复的数据
     * @param byProductPriceBeans 需要检查的数据
     * @return List<ByProductPriceBean> 不重复的数据
     */
    private List<ByProductPriceBean> checkDataBase(List<ByProductPriceBean> byProductPriceBeans) {
        if (CollectionUtils.isEmpty(byProductPriceBeans)) {
            return null;
        }
        ByProductPriceBeanExample byProductPriceBeanExample = new ByProductPriceBeanExample();
        Criteria criteria = byProductPriceBeanExample.createCriteria();
        Map<String, ByProductPriceBean> byProductPriceBeanMap = new HashMap<>();
        for (ByProductPriceBean byProductPriceBean : byProductPriceBeans) {
            byProductPriceBeanMap.put(byProductPriceBean.getByProdPriceNo(), byProductPriceBean);
        }
        //查询数据库是否有重复数据
        ArrayList<String> onlykey = new ArrayList<>(byProductPriceBeanMap.keySet());
        criteria.andByProdPriceNoIn(onlykey);
        List<ByProductPriceBean> byProductPriceBeans1 = byProductPriceBeanMapper.selectByExample(byProductPriceBeanExample);
        List<ByProductPriceBean> oldByProductPriceBean = new ArrayList<>();
        //用数据库的数据和同步过来的数据进行比对
        for (ByProductPriceBean byProductPriceBean : byProductPriceBeans1) {
            if (byProductPriceBeanMap.containsKey(byProductPriceBean.getByProdPriceNo())) {
                oldByProductPriceBean.add(byProductPriceBeanMap.get(byProductPriceBean.getByProdPriceNo()));
                byProductPriceBeanMap.remove(byProductPriceBean.getByProdPriceNo());
            }
        }
        //不重复的数据
        byProductPriceBeans = new ArrayList<>(byProductPriceBeanMap.values());
        for (int i = 0; i < byProductPriceBeans.size(); i++) {
            //价格日期起 日期时间拼接
            String priceDates = UtilDate.getDateStr(byProductPriceBeans.get(i).getPriceDates());
            if (byProductPriceBeans.get(i).getPriceTimes() != null) {
                priceDates = priceDates + byProductPriceBeans.get(i).getPriceTimes();
            }
            Date priceDatesTime = UtilDate.getDateFromStr(priceDates);
            byProductPriceBeans.get(i).setPriceDates(priceDatesTime);

            //价格日期终 日期时间拼接
            String priceDatef = UtilDate.getDateStr(byProductPriceBeans.get(i).getPriceDatef());
            if (byProductPriceBeans.get(i).getPriceTimef() != null) {
                priceDatef = priceDatef + byProductPriceBeans.get(i).getPriceTimef();
            }
            Date priceDatefTime = UtilDate.getDateFromStr(priceDatef);
            byProductPriceBeans.get(i).setPriceDatef(priceDatefTime);

            //创建日期 日期时间拼接
            String createDate = UtilDate.getDateStr(byProductPriceBeans.get(i).getCreateDate());
            if (byProductPriceBeans.get(i).getCreateTime() != null) {
                createDate = createDate + byProductPriceBeans.get(i).getCreateTime();
            }
            Date createDateTime = UtilDate.getDateFromStr(createDate);
            byProductPriceBeans.get(i).setCreateDate(createDateTime);

            //修改日期 日期时间拼接，由于有的没有修改日期所以需要判定当有修改日期和有修改时间时进行拼接入参
            if (byProductPriceBeans.get(i).getUpdateTime() != null && byProductPriceBeans.get(i).getUpdateDate() != null) {
                String upDateDate = UtilDate.getDateStr(byProductPriceBeans.get(i).getUpdateDate());
                upDateDate = upDateDate + byProductPriceBeans.get(i).getCreateTime();
                Date upDateDateTime = UtilDate.getDateFromStr(upDateDate);
                byProductPriceBeans.get(i).setUpdateDate(upDateDateTime);
            }

            byProductPriceBeans.get(i).setDateCreateTime(new Date());
            byProductPriceBeans.get(i).setVersionInt(0);
        }
        //当存在重复数据时
        if (!CollectionUtils.isEmpty(oldByProductPriceBean)) {
            //复用对象
            byProductPriceBeanMap.clear();
            for (ByProductPriceBean byProductPriceBean : oldByProductPriceBean) {
                byProductPriceBeanMap.put(byProductPriceBean.getByProdPriceNo(), byProductPriceBean);
            }
            //细致比对取出差异数据然后线程修改
            List<ByProductPriceBean> receivingGoodsBeansList = equlstDateChange(byProductPriceBeanMap);
            if (!CollectionUtils.isEmpty(receivingGoodsBeansList)) {
                AsynchronousUpDate asynchronousUpDate = new AsynchronousUpDate(receivingGoodsBeansList);
                new Thread(asynchronousUpDate).start();
            }
        }
        return byProductPriceBeans;
    }

    /**
     * @param byProductPriceBeanMap 重复的数据
     * @return List<ByProductPriceBean> 重复且有差异的信息
     * @Description 校验比较返回重复且有差异的的信息
     * @author jia chang bao
     * @date 2020/11/9 17:17
     */
    private List<ByProductPriceBean> equlstDateChange(Map<String, ByProductPriceBean> byProductPriceBeanMap) {
        if (byProductPriceBeanMap.isEmpty()) {
            return null;
        }
        //将条件分割查询出重复的数据进行比对
        ByProductPriceBeanExample byProductPriceBeanExample = new ByProductPriceBeanExample();
        Criteria criteria = byProductPriceBeanExample.createCriteria();
        ArrayList<String> onlykey = new ArrayList<>(byProductPriceBeanMap.keySet());
        criteria.andByProdPriceNoIn(onlykey);
        //重复的数据
        List<ByProductPriceBean> byProductPriceBeans = byProductPriceBeanMapper.selectByExample(byProductPriceBeanExample);
        Map<String, ByProductPriceBean> dbMap = new HashMap<>();
        for (ByProductPriceBean itemBean : byProductPriceBeans) {
            dbMap.put(itemBean.getByProdPriceNo(),itemBean);
        }
        //需要修改的数据
        List<ByProductPriceBean> byProductPriceBeanList = new ArrayList<>();
        //用数据库出来的数和重复的数据进行比对，如果发现有不一致的数判定为需要修改的重复数据
//        for (ByProductPriceBean byProductPriceBean : byProductPriceBeans) {
//            if (byProductPriceBeanMap.containsKey(byProductPriceBean.getByProdPriceNo())) {
//                ByProductPriceBean productPriceBean = byProductPriceBeanMap.get(byProductPriceBean.getByProdPriceNo());
//                //比较数据，当有一项重复则判定为需要修改
//                if (!productPriceBean.getByProdPriceNo().equals(byProductPriceBean.getByProdPriceNo())) {
//                    productPriceBean.setId(byProductPriceBean.getId());
//                    productPriceBean.setDateUpdateTime(new Date());
//                    productPriceBean.setVersionInt(byProductPriceBean.getVersionInt() + 1);
//                    byProductPriceBeanList.add(productPriceBean);
//                }
//            }
//        }
        for (Map.Entry<String, ByProductPriceBean> mapEntry : dbMap.entrySet()) {
            String byProdPriceNo = mapEntry.getKey();
            ByProductPriceBean itemBean = mapEntry.getValue();
            if (byProductPriceBeanMap.containsKey(byProdPriceNo)) {
                ByProductPriceBean productPriceBean = byProductPriceBeanMap.get(byProdPriceNo);
                //比较数据，当有一项重复则判定为需要修改
                if (!StringUtils.equalsIgnoreCase(itemBean.getStatus(),productPriceBean.getStatus()) || itemBean.getPriceDatef().compareTo( productPriceBean.getPriceDatef())!=0
                        || itemBean.getPriceDates().compareTo(productPriceBean.getPriceDates())!=0 || itemBean.getPrice().compareTo(productPriceBean.getPrice())!=0) {
                    productPriceBean.setId(itemBean.getId());
                    productPriceBean.setDateUpdateTime(new Date());
                    productPriceBean.setVersionInt(itemBean.getVersionInt() + 1);
                    byProductPriceBeanList.add(productPriceBean);
                }
            }
        }
        //需要需改的重复数据
        return byProductPriceBeanList;
    }

    /***
     * 线程修改数据
     */
    private class AsynchronousUpDate implements Runnable {
        List<ByProductPriceBean> byProductPriceBeans;

        public AsynchronousUpDate(List<ByProductPriceBean> byProductPriceBeans) {
            this.byProductPriceBeans = byProductPriceBeans;
        }

        @Override
        public void run() {
            try {
                if (!CollectionUtils.isEmpty(byProductPriceBeans)) {
                    //记录总需改数据
                    int i = 0;
                    long begintime = System.currentTimeMillis();
                    for (ByProductPriceBean byProductPriceBean : byProductPriceBeans) {
                        i += updateByProductPriceBean(byProductPriceBean);
                    }
                    long endtime = System.currentTimeMillis();
                    long costTime = (endtime - begintime);
                    log.info("异步修改副产品单价信息成功，本次修改" + i + "条数据，耗时" + costTime + "毫秒");
                }
            } catch (Exception e) {
                log.error("同步后的差异数据修改失败，错误原因：", e);
            }
        }
    }

    /**
     * sql拼接
     *
     * @param criteria               sql拼接
     * @param paraByProductPriceBean 参数
     */
    private void getSearchData(Criteria criteria, ParaByProductPriceBean paraByProductPriceBean) {
        //公司别
        if (StringUtils.isNotBlank(paraByProductPriceBean.getCompId())) {
            criteria.andCompIdEqualTo(paraByProductPriceBean.getCompId());
        }
        //价格日期起
        if (paraByProductPriceBean.getPriceDates() != null) {
            criteria.andPriceDatesEqualTo(paraByProductPriceBean.getPriceDates());
        }
        //价格日期终
        if (paraByProductPriceBean.getPriceDatef() != null) {
            criteria.andPriceDatefEqualTo(paraByProductPriceBean.getPriceDatef());
        }
        //客户编号
        if (StringUtils.isNotBlank(paraByProductPriceBean.getCustNo())) {
            criteria.andCustNoEqualTo(paraByProductPriceBean.getCustNo());
        }
        //产品形态
        if (StringUtils.isNotBlank(paraByProductPriceBean.getProdType())) {
            criteria.andProdTypeEqualTo(paraByProductPriceBean.getProdType());
        }
        //副产品单价
        if (paraByProductPriceBean.getPrice() != null && paraByProductPriceBean.getPrice().signum() > 0) {
            criteria.andPriceEqualTo(paraByProductPriceBean.getPrice());
        }
        //建立人员
        if (StringUtils.isNotBlank(paraByProductPriceBean.getCreateEmpNo())) {
            criteria.andCreateEmpNoEqualTo(paraByProductPriceBean.getCreateEmpNo());
        }
        //建立日期
        if (paraByProductPriceBean.getCreateDate() != null) {
            criteria.andCreateDateEqualTo(paraByProductPriceBean.getCreateDate());
        }
        //修改人员
        if (StringUtils.isNotBlank(paraByProductPriceBean.getUpdateEmpNo())) {
            criteria.andUpdateEmpNoEqualTo(paraByProductPriceBean.getUpdateEmpNo());
        }
        //修改日期
        if (paraByProductPriceBean.getUpdateDate() != null) {
            criteria.andUpdateDateEqualTo(paraByProductPriceBean.getUpdateDate());
        }
        //状态
        if (StringUtils.isNotBlank(paraByProductPriceBean.getStatus())) {
            criteria.andStatusEqualTo(paraByProductPriceBean.getStatus());
        }
        //省
        if (StringUtils.isNotBlank(paraByProductPriceBean.getProvince())) {
            criteria.andProvinceEqualTo(paraByProductPriceBean.getProvince());
        }
        //市
        if (StringUtils.isNotBlank(paraByProductPriceBean.getCity())) {
            criteria.andCityEqualTo(paraByProductPriceBean.getCity());
        }
        //县
        if (StringUtils.isNotBlank(paraByProductPriceBean.getConty())) {
            criteria.andContyEqualTo(paraByProductPriceBean.getConty());
        }
        //创建时间
        if (paraByProductPriceBean.getDateCreateTime() != null) {
            criteria.andDateCreateTimeEqualTo(paraByProductPriceBean.getDateCreateTime());
        }
        if (paraByProductPriceBean.getVersionInt() != null && paraByProductPriceBean.getVersionInt() > 0) {
            criteria.andVersionIntEqualTo(paraByProductPriceBean.getVersionInt());
        }

        //修改时间
        if (paraByProductPriceBean.getDateUpdateTime() != null) {
            criteria.andDateUpdateTimeEqualTo(paraByProductPriceBean.getDateUpdateTime());
        }
        //时间在有效期内的副产品价格数据
        if(paraByProductPriceBean.getPriceEffectTime() != null){
            criteria.andPriceDatesLessThanOrEqualTo(paraByProductPriceBean.getPriceEffectTime()).andPriceDatefGreaterThan(paraByProductPriceBean.getPriceEffectTime());
        }
    }

    /**
     * 中冠视图请求的参数校验
     *
     * @param zgViewBean 视图名称
     * @return 校验结果
     */
    private String checkData(ZgViewBean zgViewBean) {
        String msg = "";
        if (!StringUtils.isNotBlank(zgViewBean.getMethod())) {
            msg += "请求方法不能为空";
        }
        if (!StringUtils.isNotBlank(zgViewBean.getViewId())) {
            msg += "请求的视图不能为空";
        }
        if (!StringUtils.isNotBlank(zgViewBean.getPageNum())) {
            msg += "请求的页码不能为空";
        }
        return msg;
    }

    /**
     * 获取单个副产品价格
     * @Title: getByProductPriceBeanByPara
     * @Description: (这里用一句话描述这个方法的作用)
     * @Param paraBean 参数说明
     * @return com.steel.yfmall.cloud.assistant.bean.result.APIResultByProductPriceBean    返回类型
     * @author yuchaohua
     * @date 2021/2/23 11:49
     */
    @Override
    public APIResultByProductPriceBean getByProductPriceBeanByPara(ParaByProductPriceBean paraBean) {
        APIResultByProductPriceBean returnBean = null;
        ByProductPriceBeanExample example = new ByProductPriceBeanExample();
        Criteria criteria = example.createCriteria();
        getSearchData(criteria, paraBean);
        //不分页结果
        ByProductPriceBean dbBean = byProductPriceBeanMapper.selectOneByExampleSelective(example);
        if (dbBean != null) {
            returnBean = new APIResultByProductPriceBean();
            MobileBaseBeanUtils.copyAllFields(dbBean, returnBean);
        }
        return returnBean;
    }

}
